package PUSHReciveParser;

public class ReadOrigInd {
	public String readReportOrigMessage;
	
	public static final String MMS_MESSAGE_TYPE = "X-Mms-Message-Type";
	public static final String MMS_VERSION = "X-Mms-MMS-Version";
	public static final String MMS_MESSAGE_ID = "Message-ID";
	public static final String MMS_TO = "To";
	public static final String MMS_FROM = "From";
	public static final String MMS_READ_STATUS = "X-Mms-Read-Status";
	public static final String MMS_DATE = "Date";
	
	private String mmsMessageType;
	private String mmsVersion;
	private String mmsMessageId;
	private String mmsTo;
	private String mmsFrom;
	private String mmsReadStatus;
	private String mmsDate;

	
	public String getMessageType(){
		return mmsMessageType;
	}
	
	public String getVersion(){
		return mmsVersion;
	}
	
	public String getMessageId(){
		return mmsMessageId;
	}
	
	public String getsTo(){
		return mmsTo;
	}

	public String getFrom(){
		return mmsFrom;
	}
	
	public String getReadStatus(){
		return mmsReadStatus;
	}
	
	public String getDate(){
		return mmsDate;
	}

	public ReadOrigInd(String readReportOrigMessage) {
		this.readReportOrigMessage = readReportOrigMessage;
	}
	
	public void parseMessage(){
		
		try{
			String[] result = readReportOrigMessage.split("\n");
			
			int i=0;			
			for(i=0 ; i<result.length ; i++);
			{
				if(result[i].startsWith(MMS_MESSAGE_TYPE))
					mmsMessageType=(result[i].substring((result[i].indexOf(':'))+1));
				
				else if(result[i].startsWith(MMS_VERSION))
					mmsVersion=result[i].substring((result[i].indexOf(':'))+1); 
				
				else if(result[i].startsWith(MMS_MESSAGE_ID))
					mmsMessageId=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_TO))
					mmsTo=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_FROM))
					mmsFrom=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_READ_STATUS))
					mmsReadStatus=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_DATE))
					mmsDate=result[i].substring((result[i].indexOf(':'))+1);
			}
			
		}catch (ArrayIndexOutOfBoundsException e){
			System.out.println("Malformed response message");
		}
	}	
}
